package com.apexwear.apexutils.data;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.apex.bluetooth.callback.GeneralCallback;
import com.apex.bluetooth.callback.RestScreenCallback;
import com.apex.bluetooth.callback.ScreenBrightnessCallback;
import com.apex.bluetooth.core.EABleManager;
import com.apex.bluetooth.enumeration.QueryWatchInfoType;

public class OffScreenData extends ViewModel {
    public MutableLiveData<Integer> getOffTime() {
        MutableLiveData<Integer> mutableLiveData = new MutableLiveData<>();
        EABleManager.getInstance().queryWatchInfo(QueryWatchInfoType.black_screen_time, new RestScreenCallback() {

            @Override
            public void mutualFail(int i) {
                mutableLiveData.postValue(0);
            }

            @Override
            public void restScreen(int i) {
                mutableLiveData.postValue(i);
            }
        });
        return mutableLiveData;
    }

    public MutableLiveData<Boolean> setOffTime(int offTime) {
        MutableLiveData<Boolean> mutableLiveData = new MutableLiveData<>();
        EABleManager.getInstance().setBlackScreenTimeout(offTime, new GeneralCallback() {
            @Override
            public void result(boolean b,int reason) {
                mutableLiveData.postValue(b);
            }
            @Override
            public void mutualFail(int i) {
                mutableLiveData.postValue(false);
            }
        });
        return mutableLiveData;
    }
}
